package cycle.reuse;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import jcolibri.cbrcore.Attribute;
import jcolibri.cbrcore.CBRCase;
import jcolibri.cbrcore.CBRQuery;
import jcolibri.method.reuse.NumericDirectProportionMethod;
import cycle.RentDescription;
import cycle.RentSolution;

public class AutoAdaptationConfig {
	
	boolean area_preco,vagas_preco,quartos_preco,suites_preco;
	CBRQuery query;
	Collection<CBRCase> selectedcases;
	
	public AutoAdaptationConfig(boolean _area_preco, boolean _vagas_preco, boolean _quartos_preco,
			boolean _suites_preco, CBRQuery _query, Collection<CBRCase> _selectedcases) {
		
		area_preco = _area_preco;
		vagas_preco = _vagas_preco;
		quartos_preco = _quartos_preco;
		suites_preco = _suites_preco;
		query = _query;
		selectedcases = _selectedcases;
		
		configure();
	}

	public void configure() {
		if(isArea_preco_Selected()) {
			NumericDirectProportionMethod.directProportion(new Attribute("areaPrivativa",RentDescription.class), 
					new Attribute("aluguelMensal",RentSolution.class), query, selectedcases);
		}
		
		if(isQuartos_preco_Selected()) {
			NumericDirectProportionMethod.directProportion(new Attribute("quartos",RentDescription.class), 
					new Attribute("aluguelMensal",RentSolution.class), query, selectedcases);
		}
		
		if(isSuites_preco_Selected()) {
			NumericDirectProportionMethod.directProportion(new Attribute("suites",RentDescription.class), 
					new Attribute("aluguelMensal",RentSolution.class), query, selectedcases);
		}
		
		if(isVagas_preco_Selected()) {
			NumericDirectProportionMethod.directProportion(new Attribute("vagasGaragem",RentDescription.class), 
					new Attribute("aluguelMensal",RentSolution.class), query, selectedcases);
		}
	}
	
	public void printAdaptionResult() {
		List<CBRCase> cases = new ArrayList<CBRCase>(selectedcases);
		for(int i=0;i<selectedcases.size();i++) {
			CBRCase _case = cases.get(i);
			RentDescription desc = (RentDescription) _case.getDescription();
			RentSolution sol = (RentSolution) _case.getSolution();
			System.out.println("Revision Result: ("+ _case.getID() + ";"+desc.getBairro()+";"+desc.getRegiao()+
					";"+desc.getAreaPrivativa()+";"+desc.getVagasGaragem()+";"+desc.getQuartos()+";"+
					desc.getSuites()+") Solution: ("+sol.getAluguelMensal()+";"+sol.getNomeEdificio()+");");
		}
	}
	
	public CBRQuery getQuery() {
		return query;
	}
	
	public Collection<CBRCase> getCases() {
		return selectedcases;
	}
	
	public int getK() {
		return this.selectedcases.size();
	}
	
	public boolean isArea_preco_Selected() {
		return area_preco;
	}

	public void setArea_preco(boolean area_preco) {
		this.area_preco = area_preco;
	}

	public boolean isVagas_preco_Selected() {
		return vagas_preco;
	}

	public void setVagas_preco(boolean vagas_preco) {
		this.vagas_preco = vagas_preco;
	}

	public boolean isQuartos_preco_Selected() {
		return quartos_preco;
	}

	public void setQuartos_preco(boolean quartos_preco) {
		this.quartos_preco = quartos_preco;
	}

	public boolean isSuites_preco_Selected() {
		return suites_preco;
	}

	public void setSuites_preco(boolean suites_preco) {
		this.suites_preco = suites_preco;
	}

}
